//
//  NightSingleton.m
//  XhlTrip
//
//  Created by dllo on 15/8/29.
//  Copyright (c) 2015年 蓝鸥科技. All rights reserved.
//

#import "NightSingleton.h"
#import "AppDelegate.h"

static NightSingleton *share = nil;
static UIView *nightview = nil;

@implementation NightSingleton


+ (NightSingleton *)defaultSingle
{
    static dispatch_once_t once;
    dispatch_once(&once, ^{
        if (!share) {
            share = [[NightSingleton alloc] init];
            
        }
        
    });

    return share;
}


- (void)nightopenY:(BOOL)yn
{
    
    // 让night也只初始化一次初始化 要不进行一次点击事件就执行一次颜色变深
    static dispatch_once_t once;
    dispatch_once(&once, ^{
        if (!nightview) {
            
            self.nightView = [[UIView alloc]initWithFrame:[UIScreen mainScreen].bounds];
            self.nightView.backgroundColor = [UIColor colorWithWhite:0 alpha:0.3];
            self.nightView.userInteractionEnabled = NO;
            
            AppDelegate *appdelega = [[UIApplication sharedApplication] delegate];
            [appdelega.window addSubview:self.nightView];
            [_nightView release];
        }
        
    });
    
    if (yn) {
        self.nightView.hidden = NO;
    } else {
        self.nightView.hidden = YES;
              
    }

}

- (instancetype)init
{
    self = [super init];
    if (self) {
        
    }
    return self;
}

- (void)dealloc
{
    [_nightView release];
    [super dealloc];
}


@end
